package com.cby.android.olive.ext

import android.widget.TextView
import androidx.core.content.ContextCompat

/**
 * @description: TextViewExt
 * @author: ChenBaoYang
 * @createDate: 2022/7/14 5:45 下午
 */

/**
 * 拓展函数：设置字体颜色
 * @receiver TextView
 * @param resId Int
 */
fun TextView.setFontColor(resId: Int) {
    this.setTextColor(ContextCompat.getColor(context, resId))
}

/**
 * textview设置左侧图标
 */
fun TextView.setDrawableLeft(resId: Int) {
    val leftD = resources.getDrawable(resId)
    this.setCompoundDrawables(leftD, null, null, null)
}

/**
 * textview设置上侧图标
 */
fun TextView.setDrawableTop(resId: Int) {
    val topD = resources.getDrawable(resId)
    this.setCompoundDrawables(null, topD, null, null)
}

/**
 * textview设置右侧图标
 */
fun TextView.setDrawableRight(resId: Int) {
    val rightD = resources.getDrawable(resId)
    this.setCompoundDrawables(null, null, rightD, null)
}

/**
 * textview设置下侧图标
 */
fun TextView.setDrawableBottom(resId: Int) {
    val bottomD = resources.getDrawable(resId)
    this.setCompoundDrawables(null, null, null, bottomD)
}